import pymysql

class DB:
    def __init__(self):
        self.conn = pymysql.connect(
            host='127.0.0.1',
            user='root',
            password='123',
            charset='utf8',
            cursorclass=pymysql.cursors.DictCursor
        )
        self.cursor = self.conn.cursor
    def update(self,sql):
        self.cursor.execute(sql)
        self.conn.commit()


    def find(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchone()


    def finds(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchall()



    def close(self):
        self.cursor.close()
        self.conn.close()
db = DB()